package week08;


	import java.util.*;

	class myComp implements Comparator<My> {

	 
	    public int compare(My o1, My o2) {
	        if(o1.quantity == o2.quantity) {
	            return o1.a.compareTo(o2.a);
	        }
	        return o2.quantity-o1.quantity;
	    }
	}
	class My {
	    String a;
	    int quantity;

	    public My(String a, int quantity) {
	        this.a = a;
	        this.quantity = quantity;
	    }

	    public String toString() {
	        return "My{" +
	                "a='" + a + '\'' +
	                ", quantity=" + quantity +
	                '}';
	    }
	

	    public class week0803 {

	    public void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        Map<String,Integer> map = new HashMap<String,Integer>();
	        while(sc.hasNextLine()) {
	            String s = sc.nextLine();
	            if(s.equals("!!!!!"))
	                break;
	            String t = "";
	            for (int i = 0; i < s.length(); i++) {
	                if(s.charAt(i) == ' ') {
	                    if(t!="") {

	                        if(map.containsKey(t)) {
	                            int k = map.get(t)+1;
	                            map.put(t,k);
	                        }
	                        else map.put(t,1);
	                    }
	                    t = "";
	                    continue;
	                }
	                if((i == s.length()-1)&&(s.charAt(i)!=' ')) {
	                    t+=s.charAt(i);
	                    if(t!="") {

	                        if(map.containsKey(t)) {
	                            int k = map.get(t)+1;
	                            map.put(t,k);
	                        }
	                        else map.put(t,1);
	                    }
	                    break;
	                }

	                t += s.charAt(i);
	            }

	        }
	        System.out.println(map.size());
	        My[] my = new My[map.size()];
	        int i = 0;
	        for (String o:
	             map.keySet()) {
	            my[i++] = new My(o,map.get(o));
	        }
	        Arrays.sort(my,new myComp());


	        for (int j = 0; j <10 ; j++) {
	            if(j == map.size()) {
	                break;
	            }
	            System.out.println(my[j].a+"="+my[j].quantity);
	        }
	        sc.close();
	    }

	}
	}
